package com.shycloud.mido.homework.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shycloud.mido.common.core.util.R;
import com.shycloud.mido.homework.api.entity.WeekDataMemberHomeworkType;
import com.shycloud.mido.homework.api.entity.WeekHomeworkTypeDetail;
import com.shycloud.mido.homework.api.vo.WeekHomeworkTypeDetailVO;
import com.shycloud.mido.homework.mapper.WeekHomeworkTypeDetailMapper;
import com.shycloud.mido.homework.service.WeekDataMemberHomeworkTypeService;
import com.shycloud.mido.homework.service.WeekHomeworkTypeDetailService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 周报数据表作业类型维度表 前端控制器
 * </p>
 *
 * @author baiqiang
 * @since 2021-06-15
 */
@RestController
@AllArgsConstructor
@RequestMapping("/homework/week-data-member-homework-type")
public class WeekDataMemberHomeworkTypeController {

	/** 周报数据表作业类型 service */
	private final WeekDataMemberHomeworkTypeService weekDataMemberHomeworkTypeService;
	/** 周报每周作业详情 service */
	private final WeekHomeworkTypeDetailService weekHomeworkTypeDetailService;
	/** 周报每周作业详情 mapper */
	private final WeekHomeworkTypeDetailMapper weekHomeworkTypeDetailMapper;

	@ApiOperation("获取本周作业数据详情")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "type", value = "作业类型（1-识谱 2-纠错）", paramType = "query", dataType = "String", required = true),
			@ApiImplicitParam(name = "memberId", value = "用户ID", paramType = "query", dataType = "String", required = true),
			@ApiImplicitParam(name = "weekId", value = "周报ID", paramType = "query", dataType = "String", required = true)
	})
	@GetMapping("getWeekPlayDataDetail")
	public R<WeekDataMemberHomeworkType> getWeekPlayDataDetail(String type, String memberId, String weekId) {
		return new R<>(weekDataMemberHomeworkTypeService.getOne(new QueryWrapper<WeekDataMemberHomeworkType>()
				.eq("type", type)
				.eq("member_id", memberId)
				.eq("week_id", weekId)));
	}

	@GetMapping("getWeekHomeworkDetail")
	public R<IPage<WeekHomeworkTypeDetailVO>> getWeekHomeworkDetail(Integer current, Integer size, String type, String memberId,
			String weekId) {
		return new R(weekHomeworkTypeDetailMapper.getWeekHomeworkDetailPage(new Page<>(current, size), type, memberId, weekId));
	}

}
